import agconnect from '@hw-agconnect/api-ohos'
import '@hw-agconnect/core-ohos'
import '@hw-agconnect/function-ohos'
// 添加用户
export const addUser = async (payload) => {
  const functionCallTable = agconnect.function().wrap("user-$latest")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "add",
    payload

  })
  return result.getValue()

}
// 添加银行卡
export const addBankCard = async (payload) => {
  const functionCallTable = agconnect.function().wrap("addcard-$latest")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "add",
    payload

  })
  return result.getValue()
}
export const queryBankCard = async (payload) => {
  const functionCallTable = agconnect.function().wrap("addcard-$latest")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "query",
    payload

  })
  return result.getValue()
}
export const queryUser = async (payload) => {
  const functionCallTable = agconnect.function().wrap("user-$latest")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "query",
    payload

  })
  return result.getValue()
}
export const patchUser = async (payload) => {
  const functionCallTable = agconnect.function().wrap("user-$latest")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "patch",
    payload

  })
  return result.getValue()
}
export const doPay = async (payload) => {
  const functionCallTable = agconnect.function().wrap("pay-records-$latest")
  // console.log("doPay")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "add",
    payload

  })
  // console.log("after")
  return result.getValue()
}
export const queryPayRecordsTotal = async (payload) => {
  const functionCallTable = agconnect.function().wrap("pay-records-$latest")
  // console.log("doPay")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "queryTotal",
    payload

  })
  // console.log("after")
  return result.getValue()
}
export const queryPayRecords = async (payload) => {
  const functionCallTable = agconnect.function().wrap("pay-records-$latest")
  // console.log("doPay")
  const result = await functionCallTable.call({
    //   操作类型，新增还是删除
    action: "query",
    payload

  })
  // console.log("after")
  return result.getValue()
}